package com.ddxz.demo.shiro.controller;

import com.ddxz.demo.shiro.dto.LoginInfo;
import com.ddxz.demo.shiro.service.ShiroService;
import com.ddxz.tool.web.dto.DdxzResponse;
import org.springframework.web.bind.annotation.*;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/11/25
 */

@RestController
public class ShiroController {
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public DdxzResponse login(@RequestBody LoginInfo info) {
        return service.login(info);
    }

    @RequestMapping(value = "/user/info", method = RequestMethod.GET)
    public DdxzResponse userInfo(@RequestParam("userId") String userId) {
        return service.getUserInfo(userId);
    }

    @RequestMapping(value = "/dept/{deptId}/detail", method = RequestMethod.GET)
    public DdxzResponse deptInfo(@PathVariable("deptId") String deptId) {
        return service.getDeptInfo(deptId);
    }

    private final ShiroService service;

    public ShiroController(ShiroService service) {
        this.service = service;
    }
}
